package com.haiheng.module_main.dialog

import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.navArgs
import com.haiheng.common.activity.RouterActivity
import com.haiheng.common.constant.RourePage
import com.haiheng.library_base.dialog.BaseDialog
import com.haiheng.library_base.dialog.FullDialog
import com.haiheng.module_main.databinding.BookCarClearHintDialogBinding
import com.haiheng.module_main.databinding.BookCarNoBookHintDialogBinding

/**
 *
 * @Des:
 * @Author: hwz
 * @Date:2024/8/23 0023
 * @Version: 1.0
 */
class BookCarClearHintDialog  : FullDialog() {
    private var listener: OnDialogClickListener? = null

    companion object{
        @JvmStatic
        fun newInstance(): BookCarClearHintDialog{
            return BookCarClearHintDialog()
        }
    }

    private lateinit var binding: BookCarClearHintDialogBinding



    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        //设置背景透明，才能显示出layout中诸如圆角的布局，否则会有白色底（框）
        dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
        dialog?.window?.decorView?.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                or View.SYSTEM_UI_FLAG_FULLSCREEN
                or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
        binding = BookCarClearHintDialogBinding.inflate(inflater,container,false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        dialog?.window?.apply { setDimAmount(0.5f) }
        binding?.ivClose.setOnClickListener {
            dismiss()
        }
        iniDate()
    }

    fun iniDate(){

        binding.slRight.setOnClickListener {
            (activity as RouterActivity).navigation(RourePage.BOOK_CAR_SCAN)
        }

        binding.slLeft.setOnClickListener {
            listener?.onClear(this)
        }

        binding.ivClose.setOnClickListener {
            dismiss()
        }

        binding.slRight.setOnClickListener {
            dismiss()
        }
    }
    fun setOnDialogListener(listener: OnDialogClickListener):BookCarClearHintDialog{
        this.listener = listener
        return this
    }
    interface OnDialogClickListener {
        fun onClear(dialog: BookCarClearHintDialog)

    }

}